﻿Public Class FormOuvrirListe
    Public Sub Reset()
        Me.ListView1.Items.Clear()
    End Sub

    Public Sub AjouterFichierSiExiste(ByVal FileName As String)
        If My.Computer.FileSystem.FileExists(FileName) Then
            If Not Me.ListView1.Items.ContainsKey(FileName) Then
                Dim oItem As ListViewItem = ListView1.Items.Add(FileName, FileName, "Doc")
                oItem.Checked = True
                Dim sFolder As String = My.Computer.FileSystem.GetParentPath(FileName)
                Dim oGroup As ListViewGroup = Me.ListView1.Groups(sFolder)
                If oGroup Is Nothing Then oGroup = Me.ListView1.Groups.Add(sFolder, sFolder)
                oItem.Group = oGroup
            End If
        Else
            If Not Me.ListBox1.Items.Contains(FileName) Then Me.ListBox1.Items.Add(FileName)
        End If
    End Sub

    Public Function ShowSiFichiers() As DialogResult
        If (Me.ListView1.Items.Count + Me.ListBox1.Items.Count) > 0 Then
            Me.ButtonOk.Enabled = (Me.ListView1.Items.Count > 0)
            Return Me.ShowDialog()
        Else
            Return DialogResult.Abort
        End If
    End Function

    Private Sub ButtonOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOk.Click
        Me.DialogResult = DialogResult.OK
        Me.Close()
    End Sub
End Class